package net.kevin.db.model;

import javax.persistence.Column;

public class TabColumn {
	@Column(name = "DATA_DEFAULT")
	private String expr;
	@Column(name = "OWNER")
	private String owner;
	@Column(name = "TABLE_NAME")
	private String tableName;
	@Column(name = "COLUMN_NAME")
	private String columnName;
	@Column(name = "DATA_TYPE")
	private String dataType;
	@Column(name = "NULLABLE")
	private String nullAble;
	@Column(name = "COMMENTS")
	private String comments;
	@Column(name = "DATA_PRECISION")
	private String dataPrecision;
	@Column(name = "DATA_SCALE")
	private String dataScale;
	@Column(name = "DATA_LENGTH")
	private String dataLength;

	public String getOwner() {
		return owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public String getColumnName() {
		return columnName;
	}

	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}

	public String getDataType() {
		return dataType;
	}

	public void setDataType(String dataType) {
		this.dataType = dataType;
	}

	public String getNullAble() {
		return nullAble;
	}

	public void setNullAble(String nullAble) {
		this.nullAble = nullAble;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	public String getExpr() {
		return expr;
	}

	public void setExpr(String expr) {
		this.expr = expr;
	}

	public String getDataPrecision() {
		return dataPrecision;
	}

	public void setDataPrecision(String dataPrecision) {
		this.dataPrecision = dataPrecision;
	}

	public String getDataScale() {
		return dataScale;
	}

	public void setDataScale(String dataScale) {
		this.dataScale = dataScale;
	}

	public String getDataLength() {
		return dataLength;
	}

	public void setDataLength(String dataLength) {
		this.dataLength = dataLength;
	}
	
	public void afterSet(){		
		if("VARCHAR2".equals(this.dataType)){
			if(this.getDataLength() != null && !"".equals(this.getDataLength())){
				this.dataType += "(" + this.getDataLength() +")";
			}
		}
		if("NUMBER".equals(this.dataType)){
			if(this.getDataPrecision() != null && !"".equals(this.getDataPrecision())){
				this.dataType += "(" + this.getDataPrecision() + "," + this.getDataScale() +")";
			}
		}
	}
}
